var readline = require('readline-sync')
readline.setDefaultOptions({ prompt: '' })
var readline = readline.prompt
let [n, m] = readline().split(' ').map((item) => parseInt(item)) // 读出n和m
let arr = readline().split(' ').map((item) => parseInt(item)) // 读出数组
let arrSort = [...arr] // 先拷贝一份
arrSort.sort((a, b) => b - a) // 降序排序
let res = new Array(n).fill(0) // 生成一个结果数组
for (let i = 0; i < n; i++) {
  let item = arr[i] // 拿到这个元素
  let itemObj = {
    index: i,
    value: item
  }
  arr[i] = itemObj
}
let max = 0
let maxIndex = 0
let maxArrIndex = 0
for (let i = 0; i < arr.length; i++) {
  if (arr[i].value > max) {
    max = arr[i].value
    maxIndex = arr[i].index
    maxArrIndex = i
  }
}
// 遍历完得到最大的数字和最大的下标
let startIndex = i - 